define(function (require) {

    var $ = require("zepto");
    var global = require("global");
    var page = require("page");
    var image = require("image");
    var sigeFn = require("sigeFn");
    var media = require("media");

    haddle_envent_fn = function () {
        global._on("start", image.lazy_bigP);
        global._on("fial", function () {
            setTimeout(function () {
                page._page.eq(page._pageNow).attr("data-translate", "");
                page._page.eq(page._pageNow)[0].style[global._prefixStyle("transform")] = "";
                page._page.eq(page._pageNow)[0].style[global._prefixStyle("transition")] = "";
                page._page.eq(page._pageNext)[0].style[global._prefixStyle("transform")] = "";
                page._page.eq(page._pageNext)[0].style[global._prefixStyle("transition")] = "";
                page._page.eq(page._pageNext).removeClass("active").addClass("f-hide");
                page._moveStart = true;
                page._moveFirst = true;
                page._pageNext = null;
                page._touchDeltaY = 0;
            }, 300);
        });
        global._on("success", function () {
            0 === page._pageNext && page._pageNow == page._pageNum - 1 && (page._firstChange = true);
            0 !== page._page.eq(page._pageNext).next(".m-page").length && sigeFn.lightapp_intro_hide(true);
            setTimeout(function () {
                sigeFn.Txt_init(page._page.eq(page._pageNow));
                page._pageNext === page._pageNum - 1 ? $(".u-arrow").addClass("f-hide") : $(".u-arrow").removeClass("f-hide");
                page._page.eq(page._pageNow).addClass("f-hide");
                page._page.eq(page._pageNow).attr("data-translate", "");
                page._page.eq(page._pageNow)[0].style[global._prefixStyle("transform")] = "";
                page._page.eq(page._pageNow)[0].style[global._prefixStyle("transition")] = "";
                page._page.eq(page._pageNext)[0].style[global._prefixStyle("transform")] = "";
                page._page.eq(page._pageNext)[0].style[global._prefixStyle("transition")] = "";
                $(".p-ct").removeClass("fixed");
                page._page.eq(page._pageNext).removeClass("active");
                page._page.eq(page._pageNext).removeClass("fixed");
                page._pageNow = page._pageNext;
                page._moveStart = true;
                page._moveFirst = true;
                page._pageNext = null;
                page._page.eq(page._pageNow).removeClass("fixed");
                page._page.eq(page._pageNow).attr("data-translate", "");
                page._touchDeltaY = 0;
                setTimeout(function () {
                    page._page.eq(page._pageNow).hasClass("z-animate") || page._page.eq(page._pageNow).addClass("z-animate");
                }, 20);
                $(".j-detail").removeClass("z-show");
                $(".txt-arrow").removeClass("z-toggle");
                $("video").each(function () {
                    this.paused || this.pause();
                }), sigeFn.Txt_init(page._page.eq(page._pageNow));
                0 === page._page.eq(page._pageNow).next(".m-page").length && (sigeFn.lightapp_intro_show(), sigeFn.lightapp_intro());
            }, 300);
            var t = page._page.eq(page._pageNow).attr("data-statics");
            sigeFn.ajaxTongji(t);
        });
        global._on("audio_play", function () {
            $.fn.coffee.start();
            $(".coffee-steam-box").show(500);
        });
        global._on("audio_pause", function () {
            $.fn.coffee.stop();
            $(".coffee-steam-box").hide(500);
        });
        global._on("video_open", function () {
            var t = media._audio;
            media._audioNode.addClass("z-low");
            $(".u-arrow").addClass("f-hide");
            $(document.body).css("height", $(window).height());
            t && t.pause();
            page.page_stop();
        });
        global._on("video_close", function () {
            var t = media._audio;
            media._audioNode.removeClass("z-low");
            $(".u-arrow").removeClass("f-hide");
            $(document.body).css("height", "100%");
            t && t.play();
            page.page_start();
        });
    };
    $(function () {
        haddle_envent_fn();
    });
});